package com.xxxx.controller;

import com.xxxx.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Author Str
 * @Date 2021/9/29 21:33
 * @Description :
 */
@Controller
@RequestMapping("/user")
public class UserController {
    // 跳转到login.jsp页面
    @RequestMapping("/t1")
    public String test1(){
        return "login";
    }

    // 处理登录请求（显示信息到另一个页面）
    @RequestMapping("/t2")
    public String test2(@RequestParam(value = "name") String name, @RequestParam(value = "password") String password, Model model){
        //1、接受前端参数
        System.out.println("用户名："+name);
        //2、将返回的结果返回前端
        User user = new User();
        user.setName(name);
        user.setPassword(password);
        model.addAttribute("msg",user);
        System.out.println(user);
        return "hello";
    }
}
